#include "QImageLoader.h"
#include "QPixelImage.h"

QImageLoader::QImageLoader(void):
_imageLoaded(false),
_pixMap(0)
{
}


QImageLoader::~QImageLoader(void)
{
	delete _pixMap;
}

int QImageLoader::loadImage(char * path){
	delete _pixMap;
	_pixMap = 0;
	_pixMap = new QPixmap(path);
	_imageLoaded = true;
	return 1;
}

int QImageLoader::bindImage(PixelImage * image){
	if(!_imageLoaded)
		return 0;
	QPixelImage * pImage = (QPixelImage *)image;
	pImage->setLoader(this);
	QLabel * label = new QLabel;
	label->setPixmap(*_pixMap);
	pImage->setLabel(label);
	return 1;
}